home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com
- Newsgroups: comp.lang.c++
- Subject: Re: Newbie Q: references
- Date: 10 Feb 1996 16:17:34 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4figeu$24l@news1.usa.pipeline.com>
- References: <4fegaq$gvc@dns.plano.net>
- NNTP-Posting-Host: pipe12.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Feb 09, 1996 03:50:50 in article <Re: Newbie Q: references>,
- 'jdunn@plano.net' wrote:
-
-
- >I'll take another pass at this with hard returns:
- >As I understand what happens under the compiler covers, when we
- >pass a reference into a method (function), what actually happens is
- >that the compiler creates another entry in it's symbol table to alias
- >the same address location. This new alias has a different scope and
- >is scoped only in the function it is passed to.
- >
- Did you read this somewhere? The scoping part is right, but how
- the reference is passed to a function is implementation-dependent.
-
- >Does that mean that the compiler actually does not put any thing at
- >all on the stack for the reference, but just allows you to use the
- >reference inside the function's scope?
- >
- No. Most implementations pass the reference the same way as a
- pointer. In other words, the only difference between a pointer
- and a reference to an object is the semantics in the language.
-
- >Is this the real reason for references ? That they take no overhead
- in the function calls and returns ?
- >
- No, overhead is the same as for pointers.
-
- As for the reason, here's a sentence from Stroustrup's book:
- "References were introduced primarily to support operator
- overloading."
- --
- Pete Grant
- Kalevi, Inc.
- Object Oriented Software Development
-